home *** CD-ROM | disk | FTP | other *** search
- property ancestor, p_opponent_jump_threshold, p_horizontal_melee_threshold, p_horizontal_environment_threshold, p_health_threshold, p_last_loc
-
- on new me, parent, sprite_ref, sprite_type, player_num
- ancestor = script("sprite.flash.opponent.ai.class").new(parent, sprite_ref, sprite_type, player_num)
- me.p_opponent_jump_threshold = 50
- me.p_horizontal_melee_threshold = 70
- me.p_horizontal_environment_threshold = 50
- me.p_health_threshold = 0.25
- return me
- end
-
- on determine_action me, inputs
- action = #stand
- if inputs.state = #dead then
- return #win
- else
- if me.p_injured then
- if inputs.ldx < (me.p_horizontal_environment_threshold * 2) then
- return [#jump_right, #jump][random(2)]
- else
- if inputs.rdx < (me.p_horizontal_environment_threshold * 2) then
- return [#jump_left, #jump][random(2)]
- else
- if inputs.dx > 0 then
- return [#jump_right, #jump, #jump_left, #walk_right][random(4)]
- else
- if inputs.dx < 0 then
- return [#jump_left, #jump, #jump_right, #walk_left][random(4)]
- end if
- end if
- end if
- end if
- else
- if inputs.attacking then
- if inputs.state = #special then
- if inputs.dx > 0 then
- action = me.fuzzy_move([#jump_left, #jump_left, #jump_left, #jump_right, #jump_right, #block])
- else
- if inputs.dx <= 0 then
- action = me.fuzzy_move([#jump_right, #jump_right, #jump_right, #jump_left, #jump_left, #block])
- end if
- end if
- return action
- else
- if (inputs.dx < (me.p_horizontal_melee_threshold * 1.5)) and (inputs.dx > (-me.p_horizontal_melee_threshold * 1.5)) then
- if inputs.dy > me.p_opponent_jump_threshold then
- if inputs.dy > 0 then
- action = [#high_punch, #high_kick][random(2)]
- else
- if inputs.dy > -me.p_opponent_jump_threshold then
- action = #mid_kick
- end if
- end if
- else
- if random(5) = 5 then
- action = me.attack(action)
- else
- if random(10) = 10 then
- action = #crouch
- else
- action = #block
- end if
- end if
- end if
- return action
- end if
- end if
- end if
- end if
- end if
- if me.p_last_loc = me.p_loc then
- if inputs.ldx < (me.p_horizontal_environment_threshold * 1.5) then
- action = me.fuzzy_move([#walk_right, #jump_right])
- else
- if inputs.rdx < (me.p_horizontal_environment_threshold * 1.5) then
- action = me.fuzzy_move([#walk_left, #jump_left])
- else
- if (inputs.dx > -me.p_horizontal_melee_threshold) and (inputs.dx < me.p_horizontal_melee_threshold) then
- action = me.attack(action, inputs)
- else
- action = me.fuzzy_move([#walk_left, #walk_right, #walk_left, #walk_right, #crouch, #block, #stand, #jump_right, #jump_left])
- end if
- end if
- end if
- else
- health_status = (me.p_health > me.p_health_threshold) or (inputs.health < me.p_health_threshold)
- health_status = health_status = (random(100) < 80)
- if health_status then
- case me.p_state of
- #walk_left, #walk_right, #stand, #crouch, #block:
- if inputs.ldx < me.p_horizontal_environment_threshold then
- action = me.fuzzy_move([#walk_right, #jump_right])
- else
- if inputs.rdx < me.p_horizontal_environment_threshold then
- action = me.fuzzy_move([#walk_left, #jump_left])
- else
- if inputs.dx > me.p_horizontal_melee_threshold then
- if inputs.op_loc[2] < 0 then
- action = me.fuzzy_move([#jump_left, #walk_left, #jump_left, #walk_left, #jump_left, #walk_left, #jump_left, #walk_left, #jump_left, #walk_left, #jump_left, #walk_left, #jump_left, #walk_left, #special])
- else
- action = me.fuzzy_move([#walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #special])
- end if
- else
- if inputs.dx < -me.p_horizontal_melee_threshold then
- if inputs.op_loc[2] < 0 then
- action = me.fuzzy_move([#jump_right, #walk_right, #jump_right, #walk_right, #jump_right, #walk_right, #jump_right, #walk_right, #jump_right, #walk_right, #jump_right, #walk_right, #jump_right, #walk_right, #special])
- else
- action = me.fuzzy_move([#walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #special])
- end if
- else
- if inputs.op_loc[2] < 0 then
- if inputs.op_loc[2] > -me.p_opponent_jump_threshold then
- action = me.attack(action, inputs)
- else
- action = me.fuzzy_move([#jump, #stand])
- end if
- else
- action = me.attack(action, inputs)
- end if
- end if
- end if
- end if
- end if
- #jump, #jump_left, #jump_right:
- action = me.jump_attack(inputs, action)
- end case
- else
- case me.p_state of
- #walk_left, #walk_right, #stand, #crouch, #block:
- if inputs.ldx < (me.p_horizontal_environment_threshold * 1.5) then
- action = me.fuzzy_move([#walk_right, #jump_right])
- else
- if inputs.rdx < (me.p_horizontal_environment_threshold * 1.5) then
- action = me.fuzzy_move([#walk_left, #jump_left])
- else
- if inputs.rdx < me.p_horizontal_environment_threshold then
- if inputs.dx > -me.p_horizontal_melee_threshold then
- action = me.fuzzy_move([#jump_left, #walk_left])
- else
- action = me.fuzzy_move([#walk_left])
- end if
- else
- if inputs.dx > -me.p_horizontal_melee_threshold then
- if inputs.op_loc[2] < -me.p_opponent_jump_threshold then
- action = me.fuzzy_move([#jump_right, #walk_right, #jump_right, #walk_right, #jump_right, #walk_right, #jump_right, #walk_right, #jump_right, #walk_right, #jump_right, #walk_right, #jump_right, #walk_right, #special])
- else
- action = me.fuzzy_move([#walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #walk_right, #special])
- end if
- else
- if inputs.dx < me.p_horizontal_melee_threshold then
- if inputs.op_loc[2] < -me.p_opponent_jump_threshold then
- action = me.fuzzy_move([#jump_left, #walk_left, #jump_left, #walk_left, #jump_left, #walk_left, #jump_left, #walk_left, #jump_left, #walk_left, #jump_left, #walk_left, #jump_left, #walk_left, #special])
- else
- action = me.fuzzy_move([#walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #walk_left, #special])
- end if
- end if
- end if
- end if
- end if
- end if
- #jump, #jump_left, #jump_right:
- action = me.jump_defend(inputs, action)
- end case
- end if
- end if
- me.p_last_loc = me.p_loc
- return action
- end
-
- on jump_attack me, inputs, action
- if (inputs.dx > -me.p_horizontal_melee_threshold) and (inputs.dx < me.p_horizontal_melee_threshold) then
- action = me.fuzzy_move([#mid_kick, #mid_kick, #mid_kick, #mid_kick, #high_punch, #high_kick])
- end if
- return action
- end
-
- on jump_defend me, inputs, action
- if (inputs.dx > -me.p_horizontal_melee_threshold) and (inputs.dx < me.p_horizontal_melee_threshold) then
- action = me.fuzzy_move([#block, #block, #block, #block, #block, #mid_kick, #high_punch, #high_kick])
- end if
- return action
- end
-
- on attack me, action
- if random(10) = 1 then
- action = #fast_kick
- else
- action = [#high_punch, #high_kick, #mid_kick][random(3)]
- end if
- return action
- end
-
- on fuzzy_move me, actions
- change_action = 0
- if random(50) = 50 then
- change_action = 1
- end if
- action = actions[random(actions.count)]
- case action of
- #walk_left:
- if change_action then
- action = #jump_left
- end if
- #walk_right:
- if change_action then
- action = #jump_right
- end if
- #jump_left:
- if change_action then
- action = #walk_left
- end if
- #jump_right:
- if change_action then
- action = #walk_right
- end if
- #jump:
- if change_action then
- action = #stand
- end if
- #stand:
- if change_action then
- action = #jump
- end if
- end case
- return action
- end
-
- on dispose me
- callAncestor(#dispose, [me])
- end
-